/**
 * 
 */
package com.roc.web.listener;

import java.util.Enumeration;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.web.context.WebApplicationContext;

import com.roc.util.ApplicationContextUtils;
import com.roc.util.constant.ConfigPropertiesUtils;
import com.roc.web.thread.MerinfoCheckThread;
import com.roc.web.timer.TimerStart;

/**
 * @author Administrator
 * 
 */
public class InitializePropertiesListener implements ServletContextListener {

	static Logger logger = LogManager
			.getLogger(InitializePropertiesListener.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.
	 * ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * javax.servlet.ServletContextListener#contextInitialized(javax.servlet
	 * .ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent arg0) {
		
		 
		logger.info("InitializePropertiesListener begin init the global properties");
		ConfigPropertiesUtils configPropertiesUtils = (ConfigPropertiesUtils) ApplicationContextUtils
				.getBean("configPropertiesUtils");
		if (configPropertiesUtils == null) {
			logger.info("configPropertiesUtils is null");
		} else {
			configPropertiesUtils.loadAllProperties();
		}
		
		/*TimerStart timerStart=(TimerStart) ApplicationContextUtils.getBean("timerStart");
		if(timerStart==null){
				logger.info("-------------timerStart is null----------");
		}else{
				timerStart.vick();
				logger.info("------------timerStart is scheduled OK------");
		}*/
		
		/*MerinfoCheckThread  mt= (MerinfoCheckThread) ApplicationContextUtils.getBean("merinfoCheckThread");
		if(null!=mt){
			 
			 mt.start();
		}*/	
		
		logger.info("InitializePropertiesListener loaded the global properties");
	}

}
